package com.itita.ww2.handler.requesthandler.science;

import java.sql.SQLException;

import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.itita.ww2.core.WW2Exception;
import com.itita.ww2.utils.handler.IRequestOper;

//
//import com.smartfoxserver.v2.entities.User;
//import com.smartfoxserver.v2.entities.data.ISFSObject;
//import com.smartfoxserver.v2.entities.data.SFSObject;
//import com.itita.ww2.core.MessageHandler;
//import com.itita.ww2.enums.DevTimeType;
//import com.itita.ww2.enums.MsgCode;
//import com.itita.ww2.enums.PushCode;
//import com.itita.ww2.game.R;
//import com.itita.ww2.game.UserService;
//import com.itita.ww2.model.user.UserProfile;
//import com.itita.ww2.utils.DevKeyUtil;
//import com.itita.ww2.utils.handler.IRequestOper;
//
///**
// * 科技升级完成
// * @author NorthLan
// *
// */
public class ScienceUpgradeComplete implements IRequestOper {

	@Override
	public boolean execute(String requestCMD, User user, ISFSObject params) throws WW2Exception, SQLException {
		//		UserProfile userProfile = UserService.getInstance().getUserProfile(user);
		//		int uid = userProfile.getUid();
		//		//
		//		ISFSObject backObj = new SFSObject();
		//		backObj.putInt(R.DATA_KEY_COUNTER, params.getInt(R.DATA_KEY_COUNTER));
		//		//
		//		String key = params.getUtfString("devKey");
		//		String scCode = DevKeyUtil.splitKey(key, 1);
		//
		//		// 当前是否在升级态
		//		if (!UserService.getInstance().haveTime(uid, DevTimeType.UPGRADE, scCode)) {
		//			MessageHandler.getInstance().sendMsg(requestCMD, backObj, user, MsgCode.BASEMAP_UNIT_NOT_UPGRADING, false);
		//			return false;
		//		}
		//
		//		// 时间是否已经达到
		//		if (!UserService.getInstance().isDevEndTime(uid, key)) {
		//			MessageHandler.getInstance().sendMsg(requestCMD, backObj, user, MsgCode.TIME_HAS_NOT_ARRIVED, false);
		//			return false;
		//		}
		//
		//		// 升级科技
		//		int newLevel = UserService.getInstance().userUnitCountOper(uid, scCode, 1, false);
		//		// 移除升级时间
		//		UserService.getInstance().removeDevTime(uid, key);
		//
		//		// 用户涨经验
		//		UserService.getInstance().growthUserExpOfBLL(userProfile, scCode);
		//		// 推消息
		//		ISFSObject pushObj = new SFSObject();
		//		pushObj.putUtfString("key", key);
		//		pushObj.putUtfString("code", scCode);
		//		pushObj.putInt("level", newLevel);
		//		MessageHandler.getInstance().pushMsg(PushCode.GAME_SCIENCE_UPGRADE_COMPLETE, pushObj, user);
		return true;
	}

}
